package Service;

import java.util.ArrayList;
import java.util.List;

import dao.ResearchDao;
import pojo.PageBean;
import pojo.Research;

public class ResearchService {
	ResearchDao cdao;
	public PageBean<Research> show(int currentPage,int pageSize) {
		cdao = new ResearchDao();
		PageBean<Research> pb = new PageBean<Research>();
		pb.setList(cdao.PageData(currentPage, pageSize));
		pb.setTotal(cdao.getTotal());
		int totalPage=(cdao.getTotal()%pageSize==0)?(cdao.getTotal()/pageSize):(cdao.getTotal()/pageSize+1);
		pb.setTotalPage(totalPage);
		pb.setCurrentPage(currentPage);
		pb.setPageSize(pageSize);
		return pb;
	}
	public List<Research> showResearchByType(int currentPage,int pageSize,int id){
		cdao = new ResearchDao();
		List<Research>list=new ArrayList<Research>();
		list=cdao.showResearchByType(currentPage, pageSize, id);
		return list;
	}
	public int add(Research p) {
		cdao=new ResearchDao();
		int flag=cdao.add(p);
		return flag;
	}

}